<?php

namespace App\Models;



class Order extends Base
{
    const PAID_SUCCESS = 1;

    const PAY_TYPE_WX = 2;
    const PAY_TYPE_ALI = 1;
    const PAY_DAREN_SEND_VIP = 3;

    const PRODUCT_TYPE_COOKBOOK = 1;
    const PRODUCT_TYPE_VIP = 2;
    const PRODUCT_TYPE_DAREN = 3;

    protected $appends = ['origin_amount_yuan', 'paid_amount_yuan'];

    public function getOriginAmountYuanAttribute() {
        return format_yuan($this->origin_amount);
    }

    public function getPaidAmountYuanAttribute() {
        return format_yuan($this->paid_amount);
    }


    public function cookbook() {
        return $this->belongsTo(CookbookSnapshot::class, 'cookbook_snopshot_id');
    }

    public function merchant() {
        return $this->belongsTo(Merchant::class, 'merchant_id');
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function category() {
        return $this->belongsTo(Category::class, 'category_id');
    }

    public function rec_merchant() {
        return $this->belongsTo(Merchant::class, 'rec_merchant_id');
    }
}
